﻿#include <iostream>
#include <vector>
#include <string>
#include <map>
using namespace std;

int main() {
    // 1. 遍历原生数组
    int arr[] = {1, 2, 3, 4, 5};
    cout << "遍历数组:" << endl;
    for (int x : arr) {
        cout << x << " ";
    }
    cout << endl;

    // 2. 遍历 vector
    vector<string> names = {"Tom", "Alice", "Bob"};
    cout << "遍历 vector<string>:" << endl;
    for (const auto& name : names) {
        cout << name << " ";
    }
    cout << endl;

    // 3. 遍历 string
    string s = "Hello";
    cout << "遍历 string:" << endl;
    for (char c : s) {
        cout << c << " ";
    }
    cout << endl;

    // 4. 遍历 map
    map<int, string> id_name = {{1, "Tom"}, {2, "Jerry"}, {3, "Lucy"}};
    cout << "遍历 map<int, string>:" << endl;
    for (const auto& [id, name] : id_name) {
        cout << "id: " << id << ", name: " << name << endl;
    }

    return 0;
}
